package com.busi.controller.dataInterfaceManagement;

import com.busi.entity.DataInterfaceManagement;
import com.busi.entity.InterfaceDetails;
import com.busi.util.HttpUtils;
import com.busi.util.PropertyUtil;
import com.zcurd.controller.BaseController;

/** ******************  类说明  *********************
 * class       :  DataInterfaceManagementController
 * @author     :  xusai
 * @version    :  1.0  
 * description :  数据接口管理
 * @see        :                        
 * 
 * ***********************************************
 * */
public class DataInterfaceManagementController extends BaseController{
	
		/**
		 * ******************  方法说明  ********************
		 * method name :  list
		 * @author     :  xusai
		 * @version    :  1.0  
		 * @description:  列表查询详细
		 * @see        :     
		 * ***********************************************
		 * */
		public void list() {
			render("list.html");
		}
		public void listData(){
			DataInterfaceManagement dataInterfaceManagement=getBean(DataInterfaceManagement.class,"");
			String body = gson.toJson(dataInterfaceManagement);
			String domain = PropertyUtil.getStrValue("new_zx.domain", "");
			String url = domain + "/api/dataInterfaceManagement/findList";
			String[][] headers = {{"Content-Type", "application/json"}};
			String jsonString = HttpUtils.doPost(url, body, headers , 3, 5, "utf-8");
			renderJson(jsonString==null?"":jsonString);		
		}
		
		/**
		 * ******************  方法说明  *********************
		 * method name :  add
		 * @author     :  xusai
		 * @version    :  1.0  
		 * description :  新增通道
		 * @see        :     
		 * ***********************************************
		 * */
		public void add() {
			render("add.html");
		}
		public void addPage() {
			DataInterfaceManagement dataInterfaceManagement=getBean(DataInterfaceManagement.class,"");
			String body = gson.toJson(dataInterfaceManagement);
			String domain = PropertyUtil.getStrValue("new_zx.domain", "");
			String url = domain + "/api/dataInterfaceManagement/addPage";
			String[][] headers = {{"Content-Type", "application/json"}};
			String jsonString = HttpUtils.doPost(url, body, headers , 3, 5, "utf-8");
			LOG.info("#addPage()响应参数========================="+jsonString);
			renderSuccess();
			/*if ("success".equals(jsonString)) {
				renderSuccess();
			}*/
		}
		
		/**
		 * ******************  方法说明  *********************
		 * method name :  delete
		 * @author     :  xusai
		 * @version    :  1.0  
		 * description :  禁用通道
		 * @see        :     
		 * ***********************************************
		 * */
		public void delete(){
			DataInterfaceManagement dataInterfaceManagement = getBean(DataInterfaceManagement.class,"");
			String body = gson.toJson(dataInterfaceManagement);
			String domain = PropertyUtil.getStrValue("new_zx.domain", "");
			String url = domain + "/api/dataInterfaceManagement/deletePage";
			String[][] headers = {{"Content-Type", "application/json"}};
			String jsonString = HttpUtils.doPost(url, body, headers, 3, 5, "utf-8");
			LOG.info("#delete()响应参数========================="+jsonString);
			renderSuccess();
		}
		
		/**
		 * ******************  方法说明  *********************
		 * method name :  detail
		 * @author     :  xusai
		 * @version    :  1.0  
		 * description :  接口详情
		 * @see        :     
		 * ***********************************************
		 * */
		public void detail() {
			InterfaceDetails interfaceDetails=getBean(InterfaceDetails.class,"");
			setAttr("wayId", interfaceDetails.getWayId());
			render("detail.html");
		}
		
		public void detailList() {
			InterfaceDetails interfaceDetails=getBean(InterfaceDetails.class,"");
			setAttr("wayId", interfaceDetails.getWayId());
			String body = gson.toJson(interfaceDetails);
			String domain = PropertyUtil.getStrValue("new_zx.domain", "");
			String url = domain + "/api/interfaceDetails/findList";
			String[][] headers = {{"Content-Type", "application/json"}};
			String jsonString = HttpUtils.doPost(url, body, headers , 3, 5, "utf-8");
			renderJson(jsonString==null?"":jsonString);		
		}
		
		/**
		 * ******************  方法说明  *********************
		 * method name :  addInterface
		 * @author     :  xusai
		 * @version    :  1.0  
		 * description :  新增接口
		 * @see        :     
		 * ***********************************************
		 * */
		public void addInterface() {
			InterfaceDetails interfaceDetails=getBean(InterfaceDetails.class,"");
			setAttr("wayId", interfaceDetails.getWayId());
			render("addInterface.html");
		}
		public void addInterfacePage() {
			InterfaceDetails interfaceDetails=getBean(InterfaceDetails.class,"");
			setAttr("wayId", interfaceDetails.getWayId());
			String body = gson.toJson(interfaceDetails);
			String domain = PropertyUtil.getStrValue("new_zx.domain", "");
			String url = domain + "/api/interfaceDetails/addPage";
			String[][] headers = {{"Content-Type", "application/json"}};
			String jsonString = HttpUtils.doPost(url, body, headers , 3, 5, "utf-8");
			LOG.info("#addInterfacePage()响应参数========================="+jsonString);
			renderSuccess();
			/*if ("success".equals(jsonString)) {
				renderSuccess();
			}*/
		}
		
		/**
		 * ******************  方法说明  *********************
		 * method name :  update
		 * @author     :  xusai
		 * @version    :  1.0  
		 * description :  修改接口（先查后改）
		 * @see        :     
		 * ***********************************************
		 * */
		public void update() {
			InterfaceDetails interfaceDetails=getBean(InterfaceDetails.class,"");
			setAttr("wayId", interfaceDetails.getWayId());
			String body = gson.toJson(interfaceDetails);
			String domain = PropertyUtil.getStrValue("new_zx.domain", "");
			String url = domain + "/api/interfaceDetails/findOne";
			String[][] headers = {{"Content-Type", "application/json"}};
			String jsonString = HttpUtils.doPost(url, body, headers , 3, 5, "utf-8");
			LOG.info("#update()响应参数========================="+jsonString);
			InterfaceDetails interfaceDetails2=gson.fromJson(jsonString, InterfaceDetails.class);
			setAttr("interfaceDetails", interfaceDetails2);
			render("updateInterface.html");
		}
		public void updateInterfacePage() {
			InterfaceDetails interfaceDetails = getBean(InterfaceDetails.class,"");
			String body = gson.toJson(interfaceDetails);
			String domain = PropertyUtil.getStrValue("new_zx.domain", "");
			String[][] headers = {{"Content-Type", "application/json"}};
			String url = domain + "/api/interfaceDetails/updatePage";
			String jsonString = HttpUtils.doPost(url, body, headers, 3, 5, "utf-8");
			LOG.info("#updateInterfacePage()响应参数========================="+jsonString);
			renderSuccess();
		}
		
		/**
		 * ******************  方法说明  *********************
		 * method name :  delete
		 * @author     :  xusai
		 * @version    :  1.0  
		 * description :  禁用通道
		 * @see        :     
		 * ***********************************************
		 * */
		public void deleteInterface(){
			InterfaceDetails interfaceDetails = getBean(InterfaceDetails.class,"");
			String body = gson.toJson(interfaceDetails);
			String domain = PropertyUtil.getStrValue("new_zx.domain", "");
			String url = domain + "/api/interfaceDetails/deletePage";
			String[][] headers = {{"Content-Type", "application/json"}};
			String jsonString = HttpUtils.doPost(url, body, headers, 3, 5, "utf-8");
			LOG.info("#delete()响应参数========================="+jsonString);
			renderSuccess();
		}
		
	
}
